package gui.scene;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;

import core.ViewableEntity;

/**
 * A view of a 2d scene.
 * 
 * @author Jason
 */
public abstract class Scene {

	/**
	 * The area at which the view is currently looking.
	 */
	protected Rectangle worldViewArea = new Rectangle();

	/**
	 * The location at which this view is focused on
	 */
	protected final Point focus = new Point();

	/**
	 * Renders the scene onto the specified pixel area.
	 */
	public void render(int x, int y, int w, int h, Graphics2D g) {
		g.translate(-(focus.x - w / 2), -(focus.y - h / 2));
		worldViewArea.setBounds(focus.x - w / 2, focus.y - h / 2, w, h);
		renderScene(g);
		g.translate(focus.x - w / 2, focus.y - h / 2);
	}

	/**
	 * Render the scene in absolute coordinates.
	 * 
	 * ex: If there is some object at coordinates 5000, 5000 draw the object at
	 * THAT pixel location.
	 * 
	 * @param g
	 */
	protected abstract void renderScene(Graphics2D g);

	/**
	 * Adds the given entity to the scene to be rendered.
	 */
	public abstract void addEntity(ViewableEntity e);

}
